class Solution(object):
    def badSensor(self, sensor1, sensor2):
        n = len(sensor1)
        for i in range(n):
            if sensor1[i] != sensor2[i]:
                if i == n - 1:
                    return -1
                else:
                    left = i
                    right = i + 1
                    l_flag = False
                    while right < n:
                        if sensor1[left] == sensor2[right]:
                            left += 1
                            right += 1
                        else:
                            break
                    if right == n:
                        l_flag = True
                    left = i + 1
                    right = i
                    while left < n:
                        if sensor1[left] == sensor2[right]:
                            left += 1
                            right += 1
                        else:
                            break
                    r_flag = False
                    if left == n:
                        r_flag = True
                    if l_flag:
                        if r_flag:
                            return -1
                        else:
                            return 1
                    else:
                        if r_flag:
                            return 2
                        else:
                            return -1
        return -1


